
import Q from './Q'

export default class ie {
  constructor(t, n, o, r) {
    this.hotInstance = t;
    this.op = n;
    this.data = o;
    this.source = r
  }

  updateCellMetaObject(e) {
    this.hotInstance.setCellMetaObject(e.row, e.col, re(e, this.hotInstance).updateCellMeta)
  }

  commit() {
    var e = this;
    switch (this.op) {
      case "changeCellStyle":
        if (!this.data)
          return;
        new Q({
          cellMetas: this.data
        }, this.hotInstance).diff().applyChange();
        break;
      case "formatPaste":
        if (!this.data)
          return;
        var t = {
          cellMetas: this.data.clonedCells
        }
          , n = this.data.mergedCells
          , o = this.hotInstance.getSettings().mergeCells;
        this.data.unMerged && (o = o.filter(function (t) {
          return !e.data.unMerged.find(function (e) {
            return e.row === t.row && e.col === t.col
          })
        })),
          t.mergeCells = o.concat(n),
          this.data.cellData && (t.cellData = this.data.cellData),
          this.data.tableStructure && (t.tableStructure = this.data.tableStructure),
          new Q(t, this.hotInstance).diff().applyChange();
        break;
      case "mergeCell":
        var r = {
          mergeCells: this.data.mergeCells,
          cellData: this.data.cellData
        };
        this.data.cellMetas && (r.cellMetas = this.data.cellMetas),
          new Q(r, this.hotInstance).diff().applyChange();
        break;
      case "unMergeCell":
        new Q({
          mergeCells: this.data.mergeCells
        }, this.hotInstance).diff().applyChange();
        break;
      case "clearContent":
      case "updateCellExpression":
      case "updateCellImg":
      case "updateCellQR":
      case "updateCellBR":
        new Q({
          cellData: this.data
        }, this.hotInstance).diff().applyChange();
        break;
      case "updateDateFormat":
        new Q({
          cellFields: this.data
        }, this.hotInstance).diff().applyChange();
        break;
      case "alterTable":
        new Q({
          tableStructure: this.data
        }, this.hotInstance).diff().applyChange();
        break;
      case "common":
        new Q(this.data, this.hotInstance).diff().applyChange();
        break;
      case "updateApprovalOpinionStyle":
        new Q({
          cellFields: this.data
        }, this.hotInstance).diff().applyChange()
    }

    window.isHandsonTableEdited = !0
  }
}